/******************************************************************************
//             INTEL CORPORATION PROPRIETARY INFORMATION
//  This software is supplied under the terms of a license agreement or
//  nondisclosure agreement with Intel Corporation and may not be copied
//  or disclosed except in accordance with the terms of that agreement.
//        Copyright (c) 2000-2001 Intel Corporation. All Rights Reserved.
//
//  Description:
//      Intel(R) JPEG library for X platform 
//
********************************************************************************/
#include "_ijx.h"


#if IPPJPVER!=1

/******************************************************************************
// Name:            ijHuffmanEncodeDC_Gray_P
// Description:     Encoding scan data for Baseline mode
// Input Arguments:
//         pSrcMCU: Identifies MCU coefficients buffer.
//              al: Indicates approximation low
//    pDecodeState: Identifies IJDECODESTATE strcuture.
// Output Arguments:
//         pStream: Identifies IJBITTREAMSTATE data structure.
//                          
// Returns:          
//        [Success] IJX_RTCODE_OK
//        [Failure] IJX_RTCODE_BAGARG
//                  IJX_RTCODE_INSUFFICIENTBUF
//                  IJX_RTCODE_ERRPARSE
//                     
//                  
******************************************************************************/
IJXRESULT ijGetHuffmanFREQ_Gray(const Ipp16s **ppMCUBuf, 
                                int **ppFreq,
                                IJENCODESTATE *pEncodeState)
{
    ippiGetHuffmanFREQ_JPEG_16s(ppMCUBuf[0],
                                ppFreq[0],
                                ppFreq[1],
                                &(pEncodeState->dcPred[0]));

//    pEncodeState->counter.nScanMCUCounter++;

    if ( (0<pEncodeState->nRstInterval) ){
        pEncodeState->counter.nDRICounter--;
        if (0==pEncodeState->counter.nDRICounter) {
            pEncodeState->counter.nDRICounter=pEncodeState->nRstInterval;
            pEncodeState->dcPred[0]=0;
        }
    }

    return IJX_RTCODE_OK;
}

/******************************************************************************
// Name:            ijHuffmanEncodeDC_444_P
// Description:     Encoding scan data for Baseline mode
// Input Arguments:
//         pSrcMCU: Identifies MCU coefficients buffer.
//              al: Indicates approximation low
//    pDecodeState: Identifies IJDECODESTATE strcuture.
// Output Arguments:
//         pStream: Identifies IJBITTREAMSTATE data structure.
//                          
// Returns:          
//        [Success] IJX_RTCODE_OK
//        [Failure] IJX_RTCODE_BAGARG
//                  IJX_RTCODE_INSUFFICIENTBUF
//                  IJX_RTCODE_ERRPARSE
//                     
//                  
******************************************************************************/
IJXRESULT ijGetHuffmanFREQ_444(const Ipp16s **ppMCUBuf, 
                               int **ppFreq,
                               IJENCODESTATE *pEncodeState)
{
    ippiGetHuffmanFREQ_JPEG_16s(ppMCUBuf[0],
                                     ppFreq[0],
                                     ppFreq[1],
                                     &(pEncodeState->dcPred[0]));

    ippiGetHuffmanFREQ_JPEG_16s(ppMCUBuf[1],
                                     ppFreq[2],
                                     ppFreq[3],
                                     &(pEncodeState->dcPred[1]));
    ippiGetHuffmanFREQ_JPEG_16s(ppMCUBuf[2],
                                     ppFreq[2],
                                     ppFreq[3],
                                     &(pEncodeState->dcPred[2]));

//    pEncodeState->counter.nScanMCUCounter++;

    if ( (0<pEncodeState->nRstInterval) ){
        pEncodeState->counter.nDRICounter--;
        if (0==pEncodeState->counter.nDRICounter) {
            pEncodeState->counter.nDRICounter=pEncodeState->nRstInterval;
            pEncodeState->dcPred[0]=0;
            pEncodeState->dcPred[1]=0;
            pEncodeState->dcPred[2]=0;
        }
    }

    return IJX_RTCODE_OK;
}

/******************************************************************************
// Name:            ijHuffmanEncodeDC_422_P
// Description:     Encoding scan data for Baseline mode
// Input Arguments:
//         pSrcMCU: Identifies MCU coefficients buffer.
//              al: Indicates approximation low
//    pDecodeState: Identifies IJDECODESTATE strcuture.
// Output Arguments:
//         pStream: Identifies IJBITTREAMSTATE data structure.
//                          
// Returns:          
//        [Success] IJX_RTCODE_OK
//        [Failure] IJX_RTCODE_BAGARG
//                  IJX_RTCODE_INSUFFICIENTBUF
//                  IJX_RTCODE_ERRPARSE
//                     
//                  
******************************************************************************/
IJXRESULT ijGetHuffmanFREQ_422(const Ipp16s **ppMCUBuf, 
                               int **ppFreq,
                               IJENCODESTATE *pEncodeState)
{
    ippiGetHuffmanFREQ_JPEG_16s(ppMCUBuf[0],
                                     ppFreq[0],
                                     ppFreq[1],
                                     &(pEncodeState->dcPred[0]));

    ippiGetHuffmanFREQ_JPEG_16s(&(ppMCUBuf[0][64]),
                                     ppFreq[0],
                                     ppFreq[1],
                                     &(pEncodeState->dcPred[0]));

    ippiGetHuffmanFREQ_JPEG_16s(ppMCUBuf[1],
                                     ppFreq[2],
                                     ppFreq[3],
                                     &(pEncodeState->dcPred[1]));
    ippiGetHuffmanFREQ_JPEG_16s(ppMCUBuf[2],
                                     ppFreq[2],
                                     ppFreq[3],
                                     &(pEncodeState->dcPred[2]));

//    pEncodeState->counter.nScanMCUCounter++;

    if ( (0<pEncodeState->nRstInterval) ){
        pEncodeState->counter.nDRICounter--;
        if (0==pEncodeState->counter.nDRICounter) {
            pEncodeState->counter.nDRICounter=pEncodeState->nRstInterval;
            pEncodeState->dcPred[0]=0;
            pEncodeState->dcPred[1]=0;
            pEncodeState->dcPred[2]=0;
        }
    }
    return IJX_RTCODE_OK;
}

/******************************************************************************
// Name:            ijHuffmanEncodeDC_411_P
// Description:     Encoding scan data for Baseline mode
// Input Arguments:
//         pSrcMCU: Identifies MCU coefficients buffer.
//              al: Indicates approximation low
//    pDecodeState: Identifies IJDECODESTATE strcuture.
// Output Arguments:
//         pStream: Identifies IJBITTREAMSTATE data structure.
//                          
// Returns:          
//        [Success] IJX_RTCODE_OK
//        [Failure] IJX_RTCODE_BAGARG
//                  IJX_RTCODE_INSUFFICIENTBUF
//                  IJX_RTCODE_ERRPARSE
//                     
//                  
******************************************************************************/
IJXRESULT ijGetHuffmanFREQ_411(const Ipp16s **ppMCUBuf, 
                               int **ppFreq,
                               IJENCODESTATE *pEncodeState)
{
    ippiGetHuffmanFREQ_JPEG_16s(ppMCUBuf[0],
                                     ppFreq[0],
                                     ppFreq[1],
                                     &(pEncodeState->dcPred[0]));

    ippiGetHuffmanFREQ_JPEG_16s(&(ppMCUBuf[0][64]),
                                     ppFreq[0],
                                     ppFreq[1],
                                     &(pEncodeState->dcPred[0]));

    ippiGetHuffmanFREQ_JPEG_16s(&(ppMCUBuf[0][128]),
                                     ppFreq[0],
                                     ppFreq[1],
                                     &(pEncodeState->dcPred[0]));

    ippiGetHuffmanFREQ_JPEG_16s(&(ppMCUBuf[0][192]),
                                     ppFreq[0],
                                     ppFreq[1],
                                     &(pEncodeState->dcPred[0]));

    ippiGetHuffmanFREQ_JPEG_16s(ppMCUBuf[1],
                                     ppFreq[2],
                                     ppFreq[3],
                                     &(pEncodeState->dcPred[1]));
    ippiGetHuffmanFREQ_JPEG_16s(ppMCUBuf[2],
                                     ppFreq[2],
                                     ppFreq[3],
                                     &(pEncodeState->dcPred[2]));

//    pEncodeState->counter.nScanMCUCounter++;

    if ( (0<pEncodeState->nRstInterval) ){
        pEncodeState->counter.nDRICounter--;
        if (0==pEncodeState->counter.nDRICounter) {
            pEncodeState->counter.nDRICounter=pEncodeState->nRstInterval;
            pEncodeState->dcPred[0]=0;
            pEncodeState->dcPred[1]=0;
            pEncodeState->dcPred[2]=0;
        }
    }
    return IJX_RTCODE_OK;
}

#endif


/* EOF */
